{% extends "base.html" %}

{% block title %}Movie List - Flask Templates Demo{% endblock %}

{% block content %}
<h2>Movie Collection</h2>

{% if movies %}
    <p>Found {{ movies|length }} movies in the collection.</p>
    
    <div class="row">
        {% for movie in movies %}
        <div class="col-md-6 col-lg-4 mb-4">
            <div class="card">
                <div class="card-body">
                    <h5 class="card-title">{{ movie.name }}</h5>
                    <p class="card-text">
                        <strong>Year:</strong> {{ movie.year }}<br>
                        <strong>Director:</strong> {{ movie.director|default('Unknown') }}<br>
                        <strong>Rating:</strong> 
                        {% if movie.rating >= 8 %}
                            <span class="badge bg-success">{{ movie.rating }}/10</span>
                        {% elif movie.rating >= 6 %}
                            <span class="badge bg-warning text-dark">{{ movie.rating }}/10</span>
                        {% else %}
                            <span class="badge bg-danger">{{ movie.rating }}/10</span>
                        {% endif %}
                    </p>
                </div>
            </div>
        </div>
        {% endfor %}
    </div>
{% else %}
    <div class="alert alert-warning">
        <p>No movies found in the collection.</p>
    </div>
{% endif %}

<div class="mt-4">
    <h3>Raw Data (for debugging)</h3>
    <pre>{{ movies|pprint }}</pre>
</div>
{% endblock %}